hackerrank ruby strings methods II solution